Page({
  data: {
    //轮播图配置
    autoplay: true,
    interval: 3000,
    duration: 1200,
    items: [{
        title: '课程',
        img: 'http://114.132.161.50:29000/hsqnb/20221010195803131.jpg'
      },

      {
        title: '班级',
        img: './class.png'
      },

      {
        title: '测评',
        img: './class.png'
      },

      {
        title: '培训',
        img: './class.png'
      },

      {
        title: '群组',
        img: './class.png'
      }
    ],


    info: [{
        colorClass: 'uni-bg-red',
        url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
        content: '内容 A'
      },

      {
        colorClass: 'uni-bg-green',
        url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
        content: '内容 B'
      },

      {
        colorClass: 'uni-bg-blue',
        url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
        content: '内容 C'
      }
    ],
    current: 0,
    mode: 'default',
    swiperDotIndex: 0,
    course: [],
    class:[]
  },
  onLoad: function () {
    var that = this;
    var data = {
      "datas": [{
          "id": 1,
          "imgurl": "http://114.132.161.50:29000/hsqnb/20221011195908457.png"
        },
        {
          "id": 2,
          "imgurl": "http://114.132.161.50:29000/hsqnb/20221011195908457.png"
        }
      ]
    };
    that.setData({
      lunboData: data.datas
    })
    that.getCourse()
    that.getClass()
  },
  getCourse(){
    var that = this;
    wx.request({
      url: 'http://114.132.161.50:8083/course/list',
      method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      header: {
        'content-type': 'application/json'
      },
      data: { //参数
        num: '0' 
      },
      success: function(res) {
        if(res.statusCode == 200){
          that.setData({   
           course : res.data,
          
          }) 
          console.log(res.data)
        }
       
      },
      fail: function() {
        wx.showToast({
          title: "网络连接失败",
          duration: 3000
        })
 
      },
    })
},

getClass(){
  var that = this;
  wx.request({
    url: 'http://114.132.161.50:8083/Class/list',
    method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    header: {
      'content-type': 'application/json'
    },
    data: { //参数
      num: '0' 
    },
    success: function(res) {
      if(res.statusCode == 200){
        that.setData({   
         class : res.data,
        
        }) 
        console.log(res.data)
      }
     
    },
    fail: function() {
      wx.showToast({
        title: "网络连接失败",
        duration: 3000
      })

    },
  })
}
})
